package com.qfjy.mapper;

import com.qfjy.entity.po.User;
import com.qfjy.entity.vo.UserVO;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    /**
     * 列表查询 全部数据
     * @return
     */
    @Select("select * from user")
    List<User> selectList();

    /**
     *  TODO 批量添加
     */
    public int insertBatch(List<User> list);

    /**
     *  TODO 批量删除
     *  delete from 表名 where id in (1,2,3,4,5);
     *  delete from 表名 where id=1 or id=2 or id=3 or id=4 or id=5
     */
    public int deleteBatch(String[] ids);

    /**
     * TODO 状态变更  0无效 1有效
     */
    @Update("update user set status=#{status} where id=#{id}")
    public int updateUserStatusById(int status,int id);

    /**
     * TODO 用户列表 条件查找
     */
    public List<User> listCondition(UserVO userVO);

    /**
     * TODO 查询所有的邮箱
     */
    @Select("select email from user")
    public List<String> selectListEmail();


    /**
     * TODO 根据wid查询user
     */
    @Select("select *  from user where wid=#{wid}")
    public User selectUserByWid(int wid);

    /**
     * TODO 根据email查询user
     */
    @Select("select *  from user where email=#{email}")
    public User selectUserByEmail(String email);

    /**
     * TODO 更新user wid值 根据email邮箱
     */
    @Update("update user set wid=#{wid} where email=#{email}")
    public int updateUserWidByEmail(int wid,String email);
}